﻿using AdverseEventReportSystem.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AdverseEventReportSystem.BLL.SchedulingSystem;
using AdverseEventReportSystem.Utils;

namespace AdverseEventReportSystem.BLL
{
    /// <summary>
    /// 排班签到
    /// </summary>
    public class SchedulingSignInManager : BaseManager
    {
        /// <summary>
        /// 保存签到
        /// </summary>
        /// <param name="signIn"></param>
        /// <returns></returns>
        public static OperateResult Save(SchedulingSignIn signIn)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                SysLoginUser loginUser = LoginManager.GetLoginUser();

                if (signIn.Id == 0)
                {
                    signIn.PersonnelId = loginUser.Personnel_id;
                    signIn.PersonnelName = loginUser.Name;
                    signIn.DepartmentCode = loginUser.CurrDepCode;
                    signIn.DepartmentName = loginUser.CurrDepName;
                    signIn.CreateUserID = loginUser.Personnel_id;
                }
                else
                {
                    signIn.UpdateUserID = loginUser.Personnel_id;
                    signIn.UpdateTime = DateTime.Now;
                }
                SchedulingSystemSoapClient service = new SchedulingSystemSoapClient();
                ResultHelperOfBoolean result = service.SaveSchedulingSignIn(signIn);
                if (!result.S)
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }
            return resultInfo;
        }
    }
        
}
